package com.cat.chapter042;

/**
 * @author cat
 * @description 装苹果
 * @create 2025/7/10 16:57
 * @since JDK17
 */

public class Solution01 {
    public static int f(int rest) {
        if (rest < 0) {
            return Integer.MAX_VALUE;
        }

        if (rest == 0) {
            return 0;
        }

        int p1 = f(rest - 6);
        int p2 = f(rest - 8);

        p1 += p1 == Integer.MAX_VALUE ? 0 : 1;
        p2 += p2 == Integer.MAX_VALUE ? 0 : 1;

        int ans = Math.min(p1, p2);
        return ans;
    }

    public static int g(int n) {
        if (n < 18) {
            if (n < 6) return -1;
            if (n == 6 || n == 8) return 1;
            if (n == 12 || n == 14 || n == 16) return 2;
        }
        return (n - 18) / 8 + 3;
    }

    public static void main(String[] args) {
        for (int i = 1; i < 50; i++) {
            int t = f(i);
            System.out.println(i + " : " + (t == Integer.MAX_VALUE ? -1 : t));
        }
    }

}
